﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="ZX.Web.UI.Controls.Login" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>系统-登录</title>
    <link href="/Styles/css.login.css" rel="stylesheet" type="text/css" />
    <link href="/Styles/css/bootstrap.css"" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="/Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="/Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="/Scripts/yui_2.9.0/build/connection/connection-min.js"></script>

</head>
<body>
    
    <div>
        <div id="Llogin">
            <div id="top">
                <div id="Ltop_left">
                    <img src="Images/png/login_logo.gif" alt="" /></div>
                <div id="Ltop_center">
                </div>
            </div>
<form id="form1" runat="server">
            <div id="center">
                <div id="Lcenter_left">
                </div>
                <div id="Lcenter_content">
                    <div id="source" style="visibility: hidden;">
                        企业号：
                        <select id="txtSource" name="dept" style="width: 134px;" runat="server">
                        </select>
                    </div>
                    <div id="Luser">
                        用户名：
                        <input id="txtUserName" type="text" value="" style="width: 130px" runat="server" />
                    </div>
                    <div id="Lpassword">
                        密码：
                        <input id="txtPassword" type="password" value="123456" style="width: 130px" runat="server" />
                    </div>
                    <div id="Lcode" style="display: <%=validateCode %>">
                        验证码：
                        <input id="txtCode" type="text" style="width: 50px" runat="server" />
                        <img id="vimg" src="VCode.aspx" style="vertical-align: bottom; cursor: pointer; width: 50px;
                            height: 25px;" onclick="javascript:document.getElementById('vimg').src='VCode.aspx?'+new Date();"
                            alt="看不清，换一张" title="看不清，换一张" runat="server" />
                    </div>
                </div>
                <div id="Lcenter_right">
                </div>
            </div>
                                <asp:ImageButton ID="LbtnLogin" CssClass="LbtnLogin" runat="server" ImageUrl="Images/png/btn_dl.gif"
                                    OnClientClick="return Login()"  Style="display:none" />
				

                                <asp:ImageButton ID="LbtnReset" CssClass="LbtnReset" runat="server" ImageUrl="Images/png/btn_qx.gif"
                                    OnClick="btnReset_Click"  Style="display:none"/>
    </form>

                    <div id="Ldown">
                        <div id="bottom_left">
                            <div id="Linf">
                            </div>
                        </div>
                        <div id="bottom_center">
                            <div id="Lbtn">
                               <button  id="btnLogin" onclick="javascript:Login();" style="width:150px;" class="btn btn-danger">登录</button>
                            </div>
                        </div>
                    </div>
        </div>
    </div>


    <script type="text/javascript">
        function Validation(type) {
            var temp = true;
            var name = document.getElementById("txtUserName").value;
            var pwd = document.getElementById("txtPassword").value;
            var code = document.getElementById("txtCode").value;
            if (name == "") {
                alert("用户名不能为空!");
                $("#txtUserName").focus();
                return false;
            }  
            if (pwd == "") {
                alert("密码不能为空!");
                $("#txtPassword").focus();
                return false;
            }
            if ($("#Lcode").css("display") == "" && code=="") {
                alert("验证码不能为空!");
                $("#txtCode").focus();
                return false;
            }
            return temp;
        }







        function Login() {

            if (!Validation()) {
                return false;
            }

            var formObject = document.getElementById('form1');
            YAHOO.util.Connect.setForm(formObject);
            var cObj = YAHOO.util.Connect.asyncRequest('POST', "login.aspx?action=login&r=" + Math.random(), callback);
            return false;
        }
        var responseSuccess = function (res) {
            //alert(res.responseText);   
            //debugger
            try {

                var str = res.responseText;

                if (str == "2") {
                    location.href = "index.aspx";
                    return;
                }
                if (str == "1") {
                    alert("用户己经过期，不能使用！");
                    $("#txtUserName").focus();
                    return;
                }
                if (str == "0") {
                    alert("用户名或密码错误，请重新输入！");
                    $("#txtPassword").focus();
                    return;
                }
                if (str == "3") {
                    alert("验证码错误，请重新输入！");
                    $("#txtCode").focus();
                    return;
                }
            }
            catch (e) {
                alert(e);
            }
            finally {
            }
        };
        var responseFailure = function (error) {
            alert("登陆失败!");
        }

        var callback = {
            success: responseSuccess,
            failure: responseFailure
        };

        $(document).ready(function () {
            $('input').bind('keyup', function (event) {
                if (event.keyCode == "13") { 
//                    if ($(this).attr("id") == "txtUserName") {
//                        $("#txtPassword").focus();
//                    }
//                    if ($(this).attr("id") == "txtPassword") {
//                        $("#txtCode").focus();
//                    }
//                    if ($(this).attr("id") == "txtCode") {
//                        Login();
//                    }
                    Login();
                }
            });

        });
    </script>

</body>
</html>
